package com.oneday.ashop.console.test;

import jdk.internal.util.xml.impl.Input;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

/**
 * socket测试
 * Created by admin on 2016/7/3.
 */
public class SocketServer {


    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8081);
        while(true) {
            String str = "";
            Socket socket = serverSocket.accept();

            InputStream is = socket.getInputStream();
            byte[] bytes = new byte[2048];
            FileOutputStream fos = new FileOutputStream(new File("C:\\Users\\admin\\Desktop\\jjj.jpg"));
           while(is.read(bytes) != -1) {
               System.out.println("正在读。。。。");
               fos.write(bytes);
           }
            System.out.println("已经读完！");
            fos.flush();
            fos.close();
        }
    }
}
